package com.lazy.demo1.handler;

import java.util.List;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledHeapByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

/**
 * 做分包粘包处理
 * @author luodan
 *
 */
public class GidDecoder extends MessageToMessageDecoder<ByteBuf> {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
        // copy the ByteBuf content to a byte array
       byte[] array = new byte[msg.readableBytes()];
       msg.getBytes(0, array);

       out.add(array);
    }

}
